//
//  DeskView.m
//  iCarStyle
//
//  Created by liunian on 13-9-6.
//  Copyright (c) 2013年 liunian. All rights reserved.
//

#import "DeskView.h"
#import <QuartzCore/QuartzCore.h>

@implementation DeskView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

- (void)layoutSubviews{
    [super layoutSubviews];
    [self.icon setFrame:self.bounds];
    [self.name setFrame:CGRectMake(5, 0, CGRectGetWidth(self.bounds) - 10, 30)];
}

#pragma mark getter
- (UIImageView *)icon{
    if (!_icon) {
        _icon = [[UIImageView alloc] initWithFrame:self.bounds];
        [_icon setBackgroundColor:[UIColor clearColor]];
        [_icon setContentMode:UIViewContentModeScaleAspectFill];
        [_icon setClipsToBounds:YES];
        
        [self addSubview:_icon];
    }
    return _icon;
}

- (UILabel *)name{
    if (!_name) {
        _name = [[UILabel alloc] initWithFrame:self.bounds];
        [_name setFont:[UIFont boldSystemFontOfSize:22]];
        [_name setBackgroundColor:[UIColor clearColor]];
        [_name setTextColor:[UIColor flatWhiteColor]];
//        [_name setShadowColor:[UIColor flatWhiteColor]];
//        [_name setShadowOffset:CGSizeMake(0, -1)];
        [_name setNumberOfLines:0];
        [_name setAdjustsFontSizeToFitWidth:YES];
        [self addSubview:_name];
    }
    return _name;
}
@end
